home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / asm_subr.arc / HEX16OUT < prev    next >
Encoding:
Text File  |  1985-12-22  |  1.5 KB  |  52 lines

  1. ;-------------------------hex16out routine begins--------------------------+
  2. ; from BLUEBOOK OF ASSEMBLY ROUTINES FOR IBM PC & XT.
  3. ;         page : 55
  4. ;
  5. ; NAME HEX16OUT
  6. ; ROUTINE FOR Conversion from 16-bit Binary to ASCII Hexidecimal
  7. ;
  8. ; FUNCTION: This routine accepts a 16-bit binary number in the DX register
  9. ; and converts it to ASCII hexidecimal form which is sent to the std input
  10. ; device.
  11. ;
  12. ; INPUT: Upon entry an 16-bit binary number is in DX
  13. ; OUTPUT: A string of ASCII digits representing a hexidecimal number is
  14. ; sent out through the std output device.
  15. ; REGISTERS USED:  No registers are modified.  DX is used for input.
  16. ; SEGMENTS REFERENCED:  None
  17. ; ROUTINES CALLED:  STDOUT
  18. ; SPECIAL NOTES: None
  19. ;
  20. ; ROUTINE TO CONVERT FROM INTERNAL 16-BIT BINARY TO ASCII HEXIDECIMAL.
  21. ;
  22. hex16out    proc    far
  23. ;
  24. ; a binary number is in DX
  25. ;
  26.     push    cx        ; save registers
  27.     push    ax
  28. ;
  29.     mov    cx,4        ; loop for a count of four
  30. ;
  31. hex16out1:
  32.     push    cx        ; save the count
  33.     mov    cl,4        ; for a count of four
  34.     rol    dx,cl        ; rotate DX left
  35. ;
  36.     mov    al,dl        ; move into AL
  37.     and    al,00Fh        ; just digit
  38.     daa            ; add 6 if A - F
  39.     add    al,0F0h        ; bump a carry if A - F
  40.     adc    al,040h        ; here is the ASCII
  41.     call    stdout        ; send it
  42. ;
  43.     pop    cx
  44.     loop    hex16out1
  45. ;
  46.     pop    ax        ; restore registers
  47.     pop    cx
  48.     ret            ; return
  49. ;
  50. hex16out    endp
  51. ;-------------------------hex16out routine ends---------------------------+
  52.